package com.ruoyi.system.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.LabProductCas;
import com.ruoyi.system.service.ILabProductCasService;

/**
 * 申请采购明细Controller
 * 
 * @author winner
 * @date 2022-03-23
 */
@RestController
@RequestMapping("/system/product_cas")
public class LabProductCasController extends BaseController {
	@Autowired
	private ILabProductCasService labProductCasService;

	/**
	 * 查询申请采购明细列表
	 */
	//@PreAuthorize("@ss.hasPermi('labdanger:using:query')")
	@GetMapping("/list_current")
	public TableDataInfo current(LabProductCas labProductCas) {
		startPage();
		List<LabProductCas> list = labProductCasService.casInventoryList(labProductCas);
		return getDataTable(list);
	}

	@GetMapping("/list_his")
	public TableDataInfo history(LabProductCas labProductCas) {
		startPage();
		List<LabProductCas> list = labProductCasService.casInventoryHistoryList(labProductCas);
		return getDataTable(list);
	}
	/**
	 * 导出申请采购明细列表
	 */
	// @PreAuthorize("@ss.hasPermi('system:casInventory:export')")
	/*@Log(title = "申请采购明细", businessType = BusinessType.EXPORT)
	@GetMapping("/export")
	public AjaxResult export(LabProductCas labProductCas) {
		List<LabProductCas> list = labProductCasService.selectLabProductCasList(labProductCas);
		ExcelUtil<LabProductCas> util = new ExcelUtil<LabProductCas>(LabProductCas.class);
		return util.exportExcel(list, "casInventory");
	}*/

	/**
	 * 获取申请采购明细详细信息
	 */
	// @PreAuthorize("@ss.hasPermi('system:casInventory:query')")
	@GetMapping(value = "/{productId}")
	public AjaxResult getInfo(@PathVariable("productId") Long productId) {
		return AjaxResult.success(labProductCasService.selectLabProductCasById(productId));
	}

	/**
	 * 新增申请采购明细
	 */
	// @PreAuthorize("@ss.hasPermi('system:casInventory:add')")
	/*@Log(title = "申请采购明细", businessType = BusinessType.INSERT)
	@PostMapping
	public AjaxResult add(@RequestBody LabProductCas labProductCas) {
		return toAjax(labProductCasService.insertLabProductCas(labProductCas));
	}*/
	
	//updateQrCode
	@PreAuthorize("@ss.hasPermi('labdanger:using:edit')")
	@Log(title = "更新二维码", businessType = BusinessType.UPDATE)
	@PutMapping
	public AjaxResult add(@RequestBody LabProductCas labProductCas) {
		return toAjax(labProductCasService.updateQrCode(labProductCas.getProductId(), labProductCas.getQrCode()));
	}

	/**
	 * 修改申请采购明细
	 */
	// @PreAuthorize("@ss.hasPermi('system:casInventory:edit')")
	/*@Log(title = "申请采购明细", businessType = BusinessType.UPDATE)
	@PutMapping
	public AjaxResult edit(@RequestBody LabProductCas labProductCas) {
		return toAjax(labProductCasService.updateLabProductCas(labProductCas));
	}*/

	/**
	 * 删除申请采购明细
	 */
	// @PreAuthorize("@ss.hasPermi('system:casInventory:remove')")
	/*@Log(title = "申请采购明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{productIds}")
	public AjaxResult remove(@PathVariable Long[] productIds) {
		return toAjax(labProductCasService.deleteLabProductCasByIds(productIds));
	}*/
}
